<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>AdminLTE 2 | Log in</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="/adminlte/vendor/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="/adminlte/vendor/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/adminlte/vendor/Ionicons/css/ionicons.min.css">
    <link rel="stylesheet" href="/adminlte/dist/css/AdminLTE.min.css">
    <link rel="stylesheet" href="/adminlte/plugins/iCheck/square/blue.css">
    <link rel="stylesheet" href="/admin/ncss/common.css">
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="/plugins/layui/layui.all.js"></script>
    <link rel="stylesheet" href="/plugins/layui/css/layui.css">
</head>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <a href="#"><b>Admin</b>LTE</a>
    </div>
    <div class="login-box-body">
        <p class="login-box-msg">登录</p>

        <form id="loginForm" action="" method="post">
            {{ csrf_field() }}
            <div class="form-group has-feedback user_name_error">
                <input type="text" name="user_name" class="form-control" placeholder="请输入您的帐号">
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback password_error">
                <input type="password" name="password" class="form-control" placeholder="请输入密码">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="form-group v_code_error">
                <div class="col-sm-7 padding-lr0"><input type="text" name="v_code" class="form-control" placeholder="请输入验证码"></div>
                <div class="col-sm-5 padding-lr0 text-right"><img id="imgVerify" style="cursor:pointer;height: 35px;" src="/admin/verify" onclick="fleshVerify();"/></div>
            </div>
            @if(session('error'))
                <div class="alert alert-danger" role="alert">
                    {{session('error')}}
                </div>
            @endif
            <div class="row">
                <div class="col-xs-8">
                </div>
                <div class="col-xs-4">
                    <button type="button" class="btn btn-primary btn-block btn-flat" style="margin-top: 20px;" onclick="login()">登录</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="/adminlte/vendor/jquery/dist/jquery.min.js"></script>
<script src="/adminlte/vendor/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="/adminlte/plugins/iCheck/icheck.min.js"></script>
<script src="/admin/njs/common.js"></script>

<script>
    function login(){
        $(".has-error").removeClass('has-error');
        nform.submit('loginForm', '{{route('admin-login')}}', function(){
            goUrl("{{route('admin-index')}}");
        }, function(res){
             var verror = res.result.validError;
             if(verror){
                 for(var key in  verror.keys){
                     $("."+verror.keys[key]+"_error").addClass('has-error');
                 }
             }
            fleshVerify();
        });
    }

    function fleshVerify(){
        $('#imgVerify').attr('src', "/admin/verify?r=" + Math.floor(Math.random() * 100));
    }

    document.onkeydown = function (event) {
        e = event ? event : (window.event ? window.event : null);
        if (e.keyCode == 13) {
            login();
        }
    }
</script>
</body>
</html>
